//
//  MANoteOneImageCell.m
//  meiang_edu
//
//  Created by 李国栋 on 2018/10/17.
//  Copyright © 2018年 com.meiang.meiang_edu. All rights reserved.
//

#import "MANoteOneImageCell.h"

#import "MACountContentViewController.h"
#import "CollectionHShowView.h"
#import "MANoteImageCell.h"
#import "MANoteDetailViewController.h"

@interface MANoteOneImageCell()



/**
 标题
 */
@property (weak, nonatomic) IBOutlet UILabel *lblTitle;

/**
 发送人
 */
@property (weak, nonatomic) IBOutlet UILabel *lblSender;

/**
 时间
 */
@property (weak, nonatomic) IBOutlet UILabel *lblTime;
@property (weak, nonatomic) IBOutlet UIImageView *imgView;

/**
 当前cell数据源
 */
@property (nonatomic ,strong) MANoteManageModel * model;

@end

@implementation MANoteOneImageCell

- (void)setCellDataWithModel:(MANoteManageModel*)model{
    _model = model;
    self.lblTitle.text = model.message_title;
    self.lblSender.text = [NSString stringWithFormat:@"发送人:%@",model.sender_name];
    self.lblContent.text = model.message_content;
    self.lblTime.text = model.send_time;
    [self.imgView ma_setImageWithURL:model.message_images placeholderImage:[UIImage imageNamed:@"picture_logo"]];

}

- (IBAction)tapDelete:(id)sender {
    if ([self.delegate respondsToSelector:@selector(noteDetailHeaderDidTapDelete:model:)]) {
        [self.delegate noteDetailHeaderDidTapDelete:self model:self.model];
    }
}

- (CGFloat)cellHeightWithModel:(MANoteManageModel*)model{
    self.lblContent.text = model.message_content;
    CGFloat height = [self.lblContent   sizeThatFits:CGSizeMake(SCREEN_WIDTH - 12*2, MAXFLOAT)].height;
    return height + 283 - 20;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    //添加长按手势
    UILongPressGestureRecognizer * longPressGesture =[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPress:)];
    
    longPressGesture.minimumPressDuration=1.5f;//设置长按 时间
    [self addGestureRecognizer:longPressGesture];
}

- (CGSize)getImageSize{
    CGFloat imageWidth = (SCREEN_WIDTH - 4*2-12*2-4*2)/3.0;
    CGFloat imageHeight = imageWidth * (68.0/108);
    return CGSizeMake(imageWidth, imageHeight);
}

-(void)longPress:(UILongPressGestureRecognizer *)longRecognizer{
    if (longRecognizer.state==UIGestureRecognizerStateBegan) {
        if ([self.delegate respondsToSelector:@selector(noteDetailHeaderDidLongPress:model:)]) {
            [self.delegate noteDetailHeaderDidLongPress:self model:_model];
        }
    }
}

@end
